package spoon.support.builder;

import dk.au.cs.peterbn.annotations.Pattern;

/**
 * Created by IntelliJ IDEA.
 * User: peter
 * Date: 11/14/11
 * Time: 12:14 PM
 * To change this template use File | Settings | File Templates.
 */
public class DualClassLoader extends ClassLoader {

    private ClassLoader additionalParent;

    public DualClassLoader() {
        super(Thread.currentThread().getContextClassLoader());
        additionalParent = Pattern.class.getClassLoader();

    }

    @Override
    public Class<?> loadClass(String name) throws ClassNotFoundException {
        Class<?> aClass = null;
        try {
            aClass = super.loadClass(name);
        } catch (ClassNotFoundException e) {
            aClass = additionalParent.loadClass(name);
        }
        return aClass;

    }
}
